from django.shortcuts import render

from book.models import Book


# Create book views here.


def book_index(request):

    return render(request, 'book/book-index.html')


def book_list(request):
    """ 获取所有书籍 """
    books = Book.objects.all()

    context = {
        'books': books,
    }
    return render(request, 'book/book-list.html', context)


def book_detail(request, bid):
    book = Book.objects.get(id=bid)
    context = {
        'book': book,
    }
    return render(request, 'book/book-detail.html', context)

